#include <jni.h>
#include <string>

extern "C" {
extern int patch_main(int argc, char *argv[]);
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_example_text_MainActivity_bsPatchApk(JNIEnv *env, jobject thiz, jstring old_apk_,
                                              jstring path_, jstring output_) {


    const char *oldApk = env->GetStringUTFChars(old_apk_, 0);
    const char *patch = env->GetStringUTFChars(path_, 0);
    const char *output = env->GetStringUTFChars(output_, 0);


    char *argv[4] = {const_cast<char *>(""), const_cast<char *>(oldApk),
                     const_cast<char *>(output),
                     const_cast<char *>(patch)};
    int rec = patch_main(4, argv);

    env->ReleaseStringUTFChars(old_apk_, oldApk);
    env->ReleaseStringUTFChars(path_, patch);
    env->ReleaseStringUTFChars(output_, output);
    return rec;
}